﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
using ALDIOrganizer;


namespace Generator
{
    public struct Candidate
    {
        public int ID;
        public bool IsStoreRunner;
        public bool ClosesOnPreviousSunday;
        public bool IsOnVisa;
        public int Hours;
        /// <summary>
        /// How many pDays is this _employee able to work On the given week? 0 - 7
        /// </summary>
        /// <remarks>
        /// This number will affect the penalty ...
        /// </remarks>
        public byte DaysAvailable;

        public bool[] Days;
        public bool[] Revisits;
        public bool[] FullDays;
        
        public int ContractHrs;

        /* NOTE: both in Equals and GetHashCode
         * we only take 'constant' values (ID and contract hours) into account.
         * Why so? Because Andrew who works 5 days a week [days=1110101] is the same
         * person as "clear" Andrew [days=00000000]. 
         * These methods are required by (I think) the Engine class so that Candidate
         * instances can be used as keys in a dictionary. */

        public override bool Equals(object obj)
        {
            if (!(obj is Candidate))
            {
                return false;
            }
            if (ContractHrs != ((Candidate)obj).ContractHrs |
                ID != ((Candidate)obj).ID)
            {
                return false;
            }
            return true;
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = ID;                
                result = (result * 397) ^ ContractHrs;                
                return result;
            }
        }

        public Candidate DeepCopy()
        {
            var copy = new Candidate
                           {
                               ID = this.ID,
                               IsStoreRunner = this.IsStoreRunner,
                               ClosesOnPreviousSunday = this.ClosesOnPreviousSunday,
                               ContractHrs = this.ContractHrs,
                               Days = Engine.ArrayDeepCopy<bool>(this.Days),
                               DaysAvailable = this.DaysAvailable,
                               Hours = this.Hours,
                               IsOnVisa = this.IsOnVisa,
                               Revisits = Engine.ArrayDeepCopy<bool>(this.Revisits),
                               FullDays = Engine.ArrayDeepCopy<bool>(this.FullDays)
                           };
            return copy;
        }


        
    }    
}
